package com.csj.ribbonservice.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @Author:ChengshaoJie
 * @Description:
 * @Date:Created in 下午 5:03 2019/4/22 0022
 */
@Service
public class HiServiceImpl implements HiService {

    @Autowired
    RestTemplate restTemplate;
    /**
     * 设置断路由方法
     * */
    @HystrixCommand(fallbackMethod = "hiError")
    public String hiService(String name) {
        System.out.println(111);
        return restTemplate.getForObject("http://eureka-client/eureka-client/hello?name=" + name, String.class);
    }

    public String hiError(String name) {
        return "hi,"+name+",sorry,error!";
    }

}
